<template>
  <el-form label-width="100px">
    <el-form-item label="名称:">
      <el-input v-model="formData.user_name"/>
    </el-form-item>
     <el-form-item label="电话:">
      <el-input v-model="formData.phone_number"/>
    </el-form-item>
     <el-form-item label="密码:">
      <el-input v-model="formData.password"/>
    </el-form-item>
    <el-form-item label="学习词本:">
      <el-select v-model="formData.learn_vocabulary" autocomplete="off" placeholder="请选择学习词本">
        <el-option label="中小学词本" value="0" />
        <el-option label="考研词本" value="1" />
        <el-option label="高中词本" value="2" />
        <el-option label="四级词本" value="3" />
        <el-option label="六级词本" value="4" />
      </el-select>
    </el-form-item>
    <el-form-item label="角色:">
      <el-select v-model="formData.role" autocomplete="off" placeholder="请选择角色">
        <el-option label="程序开发者" value="1" />
        <el-option label="管理员" value="2" />
        <el-option label="会员用户" value="3" />
        <el-option label="普通用户" value="4" />
      </el-select>
    </el-form-item>
    <el-form-item style="float: right;margin: 20px">
      <el-button type="default" @click="updateUser">提交</el-button>
    </el-form-item>

  </el-form>
</template>

<script>
import axios from "axios";
import {ElMessage} from "element-plus";

export default {
  name: "index",
  data(){
    return{
      updData:{
        user_name:null,
        phone_number:null,
        password:null,
        Learn_vocabulary:null,
        role:null
      }
    }
  },props:{
    formData:{
      type:Object
    }
  },
  methods:{
    updateUser(){
      axios({
        method:"POST",
        url:"http://39.101.199.5:8888/SuJiWords/user/updateUser",
        data: JSON.stringify({
          "user_id":this.formData.user_id,
          "user_name":this.formData.user_name,
          "phone_number":this.formData.phone_number,
          "password":this.formData.password,
          "Learn_vocabulary":this.formData.Learn_vocabulary,
          "role":this.formData.role
        }),
        headers:{'Content-Type':'application/json;charser=UTF-8'}
      }).then(response=>(ElMessage.success(response.data.msg)))
    }
  }
  ,
  created() {
   this.updData = this.formData
    console.log(this.updData)
  }
}
</script>

<style scoped>

</style>